"""
    Controller for m2m plan transfer table.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class PlanTransferController(LookupController, CRUDController):
    model_object = model.PlanTransfer
    lookup_columns = [
        TableCol(name='current_plan', caption=_('Current plan')),
        TableCol(name='next_plan', caption=_('Next plan')),
        TableCol(name='comment', caption=_('Comment')),
    ]
    view_fields = ['currentPlanID', 'nextPlanID', 'comment']

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('plan_transfer_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = PlanTransferController()
